
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="header.js"></script>
    <script type="text/javascript" src="likeKomeng.js"></script>
    <script type="text/javascript" src="dislikeKomeng.js"></script>
    <script type="text/javascript" src="achievement.js"></script>
    <script type="text/javascript" src="hapusKomeng.js"></script>    
    <link href="css/header.css" rel="stylesheet" type="text/css" media="screen" />	
  </head>
  <body>
    <div id="menu">
      <ul>
        <li><img src="images/logo.jpg" height="80" alt="LOGO"></li>
        <li><a href="index.jsp" class="header">Home</a></li>
        <li><a href="contentlist.jsp" class="header">Content List</a></li>
        <%
          Cookie[] list = request.getCookies();
          Cookie username = null;
          Cookie id = null;
          if (list != null) {
            for (int i = 0; i < list.length; i++) {
              if ("username".equals(list[i].getName())) {
                username = list[i];
              }
              if ("id".equals(list[i].getName())) {
                id = list[i];
              }
            }
          }
          if (username != null) {
            out.write("<li><a href='post.jsp' class='header'>Post</a></li>");
          } else {
            out.write("<li><a href='registration.jsp' class='header'>Register</a></li>");
          }
        %>
        <li><form action="searchpage.jsp" method="get" name="searchform">
            <input type="text" name="q" size="20">
            <select name="type">
              <option value="1">All</option>
              <option value="2">Username</option>
              <option value="3">Content</option>
            </select>
            <input type="submit" value="search" title="Search">
          </form>
          <%
            if (username != null) {
              out.write("<li class='login' >"
                      + "<a href='profile.jsp?pid='"+id+" class='login'>Welcome,"+username.getValue()+" </a>"
                      + "</li>"
                      + "<li>"
                      + "<input type='button' value='Log Out' onclick='logOut()'>"
                      + " </li>"
                      + "<li>"
                      + "<img src='upload/avatar/' widht=100 height=100>"
                      + "</li>");
            } else {%>
        <li> <table cellspacing ='0' >
            <tbody>
              <tr>
                <td class='login'>
                  <label for='email'>Username</label>
                </td>
                <td class='login'>
                  <label for='pass'>Password</label>
                </td>
              </tr>
              <tr>
                <td>
                  <input type='text' class='inputtext' name='username' id='username' tabindex='1'>
                </td>
                <td>
                  <input type='password' class='inputtext' name='password' id='password' tabindex='2'>
                </td>
                <td>
                  <label class='uibutton' id='loginbutton'>
                    <input type='button' value='Log In' onclick='validateUser()'>
                  </label>
                </td>
              </tr>
              <tr>
                <td  colspan=3>
                  <label for='notification' id='response' class='notification'></label>
                </td>
              </tr>
            </tbody>
          </table>
        </li>
        <%              }
        %>
      </ul>
    </div>